<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <style>
        body{height: 2500px;}
        .head{
            position: fixed;
            top: 0;
            left: 0;
            height: 100px;
        }
        div{
            background-color: red;
            height: 100px;
            width: 100px;
        }
        #html{
            margin-top: 500px;
        }
        #css{
            margin-top: 500px;
        }
        #js{
            margin-top: 500px;
        }
    </style>
</head>
<body>
    <p class="head">
        <a href="#html">html</a>
        <a href="#css">css</a>
        <a href="#js">js</a>
    </p>
    <div id="html">html</div>
    <div id="css">css</div>
    <div id="js">js</div>
    <script>
        $(".head a").click(function(){
            var id =$(this).attr("href");
        var offsetTop = $(id).offset().top;
        $("html,body").animate({scrollTop:offsetTop});
        return false;
        })
    </script>
</body>
</html>